<html>
<head>
<title>管理系统</title>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<#include "../inc/commonJs.html">
<script type="text/JavaScript">
var grid, windowparam = '';
//页面加载  
$(function(){ 
	//加载数据  
    grid = $('#workloggrid').datagrid({  
        url:'listWorkLog.do',  
        loadMsg:'数据加载中请稍后……',  
        pagination: true,  
        rownumbers: true,   
        striped: true,  
        singleSelect : true,  
        pageSize: [${syscfg.pageSize!10}],
        pageList: [${syscfg.pageList!10}],
        columns:[[  
             {field:'logid',title: 'ID',align: 'center',width: '50'},  
             {field:'projectName',title: '所属项目',align: 'center',width: '200'},
             {field:'content',title: '内容',align: 'center',width: '480'},
             {field:'dt',title: '时间',align: 'center',width: '150'}
         ]],
         toolbar : '#toolbar'
     });
     $("#tree").tree({
            method: "post",
            lines: true,
            url: "${request.contextPath}/xadmin/work/listProjectForTree.do",
            dataPlain: true,       //该属性用以启用当前 easyui-tree 控件对平滑数据格式的支持
            toggleOnClick: false,
            enableContextMenu: false,
            onClick: function(node){
            	var params = {};
            	windowparam = node.id;
				params['projectid'] = node.id;
				$('#workloggrid').datagrid('reload',params); 
			}
        });
});  
	function doAdd() {
		var modalwindow = window.top.modalwindow('${request.contextPath}/xadmin/work/workLogWindow.do?windowparam='+windowparam,$('#workloggrid'),{    
		    width:450,    
		    height:250,
		    modal:true,
		    resizable:true,
		    title:'新增工作日志信息',
		    buttons:[{
				text:'保存',
				iconCls:"icon-save",
				handler:function(){
					modalwindow.find('iframe').get(0).contentWindow.saveObj('');
				}
			},{
				text:'关闭',
				iconCls:"icon-cancel",
				handler:function(){
					modalwindow.dialog('close');
				}
			}]   
		});
	};
	
	function doEdit() {
		var selected = $('#workloggrid').datagrid('getSelected');
		if(!selected){
			window.top.$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		var modalwindow =  window.top.modalwindow('${request.contextPath}/xadmin/work/workLogWindow.do?logid='+selected.logid,$('#workloggrid'),{    
		    width:450,    
		    height:250,
		    modal:true,
		    resizable:true,
		    title:'修改工作日志信息',
		    buttons:[{
				text:'保存',
				iconCls:"icon-save",
				handler:function(){
					modalwindow.find('iframe').get(0).contentWindow.saveObj(selected.logid);
				}
			},{
				text:'关闭',
				iconCls:"icon-cancel",
				handler:function(){
					modalwindow.dialog('close');
				}
			}]   
		});
	};
	
	function doDel(){
		var selected = $('#workloggrid').datagrid('getSelected');
		if(!selected){
			window.top.$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		window.top.$.messager.confirm('系统提示', '<br>&nbsp;&nbsp;&nbsp;&nbsp;你确定要删除该信息?', function(r) {
			if (r) {
				$.post("${request.contextPath}/xadmin/work/delWorkLog.do", { "logid": selected.logid},
				   function(data){
				   	$('#workloggrid').datagrid('reload'); 
				   	window.top.$.messager.alert('提示',data);
				   	
				});
			}
		});
	}

	//刷新
	function doReload(){
		$('#toolbar input').val('');
		grid.datagrid('reload',{});
	}
	//搜索
	function doSearch(){
		var params = {};
		if($('#dt').datebox('getValue')){
			params['dt'] = $('#dt').datebox('getValue');
		}
		if($('#content').datebox('getValue')){
			params['content'] = $('#content').datebox('getValue');
		}
		grid.datagrid('reload',params);
	}

</script>

</head>
<body class="easyui-layout" id="body">
<div data-options="region:'west',split:true,iconCls:'icon-mini-add',title:'按项目查找',collapsed:false" style="width:180px;">
	<div class="easyui-panel" data-options='fit:true,border:false'> 
		<ul id="tree"></ul>
	</div>
</div>   
<div data-options="region:'center',title:'工作日志'">
<table id="workloggrid" data-options="fit:true,border:false"></table>
</div>  
<div id="toolbar" style="display: none;">
<table border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td valign="center">
	&nbsp;开始日期：	<input class="easyui-datebox" type="text" id="dt" name="dt" maxlength="30" style="width:150px;">
	</td>
	<td valign="center">
	&nbsp;结束日期：<input class="easyui-datebox" type="text" id="content" name="content" maxlength="30" style="width:150px;">
	</td>
	<td valign="center">	
	<a href="javascript:doSearch();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">搜索</a>
	</td>
	<td valign="center">
	<td valign="center"><div class="datagrid-btn-separator"></div></td>
	</td>
	<td valign="center">
	<a href="javascript:doReload();" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true">刷新</a>
	</td>
	<td valign="center"><div class="datagrid-btn-separator"></div></td>
	<td valign="center" align="left">
	<a href="javascript:doAdd();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">增加</a>
	</td>
	<td valign="center" align="left">
	<a href="javascript:doEdit();" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改</a>
	</td>
	<td valign="center" align="left">
	<a href="javascript:doDel();" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true">删除</a>
	</td>
	<td valign="center"><div class="datagrid-btn-separator"></div></td>
</tr>
</table>
</div>
</body>
</html>